<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="zh">
<head>        
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
    
    <!--[if gt IE 8]>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />        
    <![endif]-->        
    
    <title>报名系统</title>
    
    <%@include file="res.jsp" %>
    
    <style type="text/css">
    	.singup_pic{width:50px;height:30px;}
    </style>
  	<script type="text/javascript">
  		function export_all(btn)
  		{
  	  		var fadeDiv = "<div id='fade_in_screen' class='modal-backdrop fade in'>this is a test</div>" ; 
  	  		$(".content").before(fadeDiv) ;  
  	  		$("#export_all_btn").after('&nbsp;&nbsp;<img id="load_img_facde" src="img/loaders/2d_4.gif">')  ; 
	  	  	$.get("<%=basePath%>page/singup_exportAll.action?time="+(new Date().valueOf()),function(data,status){
	  	     	$("#fade_in_screen").remove() ; 
	  	     	$("#load_img_facde").remove() ; 
	  	     	window.location.href='<%=basePath%>page/singup_manager.action' ;
	  	    });
  		}
  		
  	</script>
    
</head>
<body>    

    <jsp:include page="header.jsp"></jsp:include>
    
    <jsp:include page="menu.jsp"></jsp:include>
   
 	<jsp:include page="com_bbs.jsp"></jsp:include>
 	
    <div class="content">
		
        <div class="row-fluid">
            <div class="span12">
                <div class="widget">
                    <div class="wrapper">
                      <form action="page/singup_manager.action" method="get">
                        <div class="input-append input-prepend">
                            <span class="add-on"><span class="icon-search"></span></span>                            
                            <input type="text" name="keyword" value="${keyword }" placeholder="搜索..." style="width: 838px;">
                            <button type="submit" class="btn btn-primary">搜索</button> 
                        </div>    
                       </form>         
                    </div>
                </div>
              
                <div class="widget">
                <div class="head">
                        <div class="icon"><i class="icosg-star3"></i></div>
                        <h2>报名列表</h2>
                    </div>
                <div class="block-fluid">
                	
                    <table width="100%" cellspacing="0" cellpadding="0" class="table-hover">
                        <thead>
                            <tr>
                                <th><div class="checker"><span><input type="checkbox" class="checkall"></span></div></th>
                                <th width="8%">
                                   	图标
                                </th>
                                <th width="30%">
                                   	标题
                                </th>
                                <th width="13%">
                                   	结束时间
                                </th>
                                <th width="8%">
                                   	标识码
                                </th>
                                <th width="9%">
                                   	状态
                                </th>
                                <th width="6%">
                                  	 已报名
                                </th>
                                <th width="7%">
                                   	下载名单
                                </th>
                                <th width="15%">
                                   	操作
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                        	<c:forEach items="${singups}" var="singup" varStatus="state">
                            <tr>
                                <td>
                                	${state.index+1 }
                                </td>
                                <td>
                                	<a href="${singup.picPath }" class="fb" rel="group"> 
                                    	<img src="${singup.picPath }" class="singup_pic" width="50" height="30px">
                                    </a>
                                </td>
                                <td>
                                    <a href="s_${singup.id }.action" target="_blank">${singup.title }</a>
                                </td>
                                <td>
                                    ${singup.endTime }
                                </td>
                                <td>
                                    ${singup.code }
                                </td>
                                <td>   
                                	
                                 	<c:choose>
                                 		<c:when test="${singup.state == 1}">
                                 		
                                 			<script type="text/javascript">
			                                	function singup_end_now(id , btn)
			                              		{
				                              		var endHtml = "<a class='tip' data-original-title='已经结束'><span class='label label-important'><span class='icon-off'></span></span></a>" ; 
			                                		$.get("<%=basePath%>page/singup_singupEnd.action?id="+id+"&time="+(new Date().valueOf()), function(result){
			                                		  	 $(btn).replaceWith(endHtml) ; 
			                                		  	 window.location.href='<%=basePath%>page/singup_manager.action' ;
			                                		 });
			                              		}
		                                	</script>
                                 		
                                 			<a class="tip" data-original-title="火热进行" onclick="singup_end_now('${singup.id}',this);" style="cursor:pointer;">
	                                 			<span class="label label-success">
	                                 				<span class="icon-fire"></span>
	                                 			</span> 
                                 			</a>
                                 		</c:when>
                                 		<c:otherwise>
	                                 		<a class="tip" data-original-title="已经结束" >
	                                 			<span class="label label-important">
	                                 				<span class="icon-off"></span>
	                                 			</span>
	                                 		</a>
                                 		</c:otherwise>
                                 	</c:choose>
                                </td>
                                <td>
                                    ${singup.num }
                                </td> 
                                <td> 
                                    <c:choose>
                                 		<c:when test="${empty singup.codePath }">
	                                 		<a class="tip"  data-original-title="未导出来">
	                                 			<span class="label label-important"> 
	                                 					<span class="icon-download-alt"></span> 
	                                 			</span>
	                                 		</a>
                                 		</c:when>
                                 		<c:otherwise>
                                 			<a class="tip" data-original-title="名单下载" href="download/l_excel.action?id=${singup.id }">
                                 				<span  class="label label-success">
                                 					<span class="icon-download-alt"></span>
                                 				</span>
                                 			</a>
                                 		</c:otherwise>
                                 	</c:choose>
                                </td> 
                                <td class="TAC"> 
                                		<a href="s_${singup.id }.action" class="tip" data-original-title="查看" target="_blank"><span class="icon-eye-open"></span></a>  
                                        &nbsp;&nbsp;
                                 		<a class="tip" data-original-title="二维码" href="download/l_qrcode.action?url=<%=basePath %>s_${singup.id }">
                                 		<span class="icon-qrcode"></span></a> 
                                        &nbsp;&nbsp;
                                        <a class="tip" data-original-title="编辑" href="page/singup_modify.action?id=${singup.id }">
                                        <span class="icon-edit"></span></a> 
                                        &nbsp;&nbsp; 
                                        <a class="tip" data-original-title="删除" onClick="return confirm('您确定要删除【${singup.title}】吗？')" href="page/singup_remove.action?ids=${singup.id }"><span class="icon-trash"></span></a>
                                    </td>
                            </tr>
                            </c:forEach>
                        </tbody>
                    </table>
                </div>      
                <div class="toolbar bottom">
                	<div class="span2">
                		<button class="btn btn-primary" id="export_all_btn" onclick="export_all(this);" type="button">一键更新</button>
                	</div>
                	<div class="span10">
                		<jsp:include page="pager_param.jsp"></jsp:include>
                	</div> 
                </div>
            </div> 

            </div>
        </div>

    </div>  

 <!-- 删除成功 -->
    <c:if test="${singup_tip == 1}">
    	<script>
    		alert("删除成功 .... ") ; 
    	</script>
    	<!-- 删除 Session记录 -->
	    <%
	    	request.getSession().removeAttribute("singup_tip") ;
	    %>
    </c:if>
    
     <!-- 修改成功 -->
    <c:if test="${singup_tip == 2}">
    	<script>
    		alert("修改成功 .... ") ; 
    	</script>
    	<!-- 删除 Session记录 -->
	    <%
	    	request.getSession().removeAttribute("singup_tip") ;
	    %>
    </c:if>
    
    

</body>
</html>

